<% unless @sector.new_record? %>
  <div style="float: right">
    <% form_tag({:action => :upload}, :multipart => true) do %>
    <p>
      Icon<br />
      <% if @sector.icon %>
        <%= image_tag url_for :controller => :documents, :action => :image, :id => @sector.icon.id %><br />
        <%= link_to 'remove', {:controller => :documents, :action => :destroy, :id => @sector.icon.id, :sector_id => @sector.id},
                                :confirm => 'Are you sure?', :method => :delete %>
      <% else %>
        <%= file_field_tag("document[icon]") %>
      <% end %>
    </p>
    <p>
      Image<br />
      <% if @sector.image %>
        <%= image_tag url_for :controller => :documents, :action => :image, :id => @sector.image.id %><br />
        <%= link_to 'remove', {:controller => :documents, :action => :destroy, :id => @sector.image.id, :sector_id => @sector.id},
                                :confirm => 'Are you sure?', :method => :delete %>
      <% else %>
        <%= file_field_tag("document[image]") %>
      <% end %>
    </p>
    <p>
      <%= hidden_field_tag 'document[sector_id]', @sector.id %>
      <%= submit_tag 'Upload' %>
    </p>
    <% end %>
  </div>
<% end %>

<% form_for(@sector) do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </p>
  <p>
    <%= f.label :hot %><br />
    <%= f.check_box :hot %>
  </p>
  <p>
    <%= f.label :order %>
    <%= f.select :order, 1..10 %>
  </p>
  <% if @sector.new_record? %>
  <p>
    <%= f.label :archived %><br />
    <%= f.check_box :archived %>
  </p>
  <% end %>
  <p>
    <%= f.label :summary %><br />
    <%= f.text_area :summary %>
  </p>
  <p>
    <%= f.label :description %><br />
    <%= f.text_area :description %>
  </p>
  <p>
    <%= f.submit @sector.new_record? ? 'Create' : 'Update' %>
  </p>
<% end %>